package io.renren.modules.contract.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.contract.entity.CorporateCheckingEntity;
import io.renren.modules.contract.service.CorporateCheckingService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;




/**
 * 
 * 
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-12-13 16:17:47
 */
@RestController
@RequestMapping("/contract/corporatechecking")
public class CorporateCheckingController {
	@Autowired
	private CorporateCheckingService corporateCheckingService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("contract:corporatechecking:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<CorporateCheckingEntity> corporateCheckingList = corporateCheckingService.queryList(query);
		int total = corporateCheckingService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(corporateCheckingList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("contract:corporatechecking:info")
	public R info(@PathVariable("id") Long id){
		CorporateCheckingEntity corporateChecking = corporateCheckingService.queryObject(id);
		
		return R.ok().put("corporateChecking", corporateChecking);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("contract:corporatechecking:save")
	public R save(@RequestBody CorporateCheckingEntity corporateChecking){
		corporateCheckingService.save(corporateChecking);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("contract:corporatechecking:update")
	public R update(@RequestBody CorporateCheckingEntity corporateChecking){
		corporateCheckingService.update(corporateChecking);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("contract:corporatechecking:delete")
	public R delete(@RequestBody Long[] ids){
		corporateCheckingService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
